ArcPadScripting
GPS Example

Description

OpenGPS attempts to open the GPS Port if it is closed.

VBScript Code

Copy Code
Sub OpenGPS
      Dim blnOpenAttempt
      
      If Not Application.GPS.IsOpen Then
            blnOpenAttempt = Application.GPS.Open
            If blnOpenAttempt Then
                  MsgBox "GPS opened successfully.", vbInformation, "GPS Open"
            Else
                  MsgBox "GPS Open Failed!", vbExclamation, "GPS Not Open"
            End If
      Else
            MsgBox "GPS is already open!", vbInformation, "GPS Open"
      End If
End Sub
Sub CloseGPS
      If Application.GPS.IsOpen Then
            Application.GPS.Close
            If Not Application.GPS.IsOpen Then
                  MsgBox "GPS closed successfully", vbInformation, "GPS Closed"
            Else
                  MsgBox "Error closing GPS!", vbExclamation, "GPS Error"
            End If
      Else
            MsgBox "GPS is already closed!", vbInformation, "GPS Closed"
      End If
End Sub

Sub DisplayGPSPositionAndQuality
'This Sub should be called when the OnPosition event occurs for the GPS object
      Dim dblAltitude, dblLatitude, dblLongitude, dblX, dblY, dblZ
      Dim dblPDOP, dblVDOP, dblHDOP, dblTDOP, dblEPE, dblHPE, dblVPE 
      
      dblAltitude = GPS.Altitude
      dblLatitude = GPS.Latitude
      dblLongitude = GPS.Longitude
      dblX = GPS.X
      dblY = GPS.Y
      dblZ = GPS.Z
      dblPDOP = GPS.Properties("PDOP")
      dblVDOP = GPS.Properties("VDOP")
      dblHDOP = GPS.Properties("HDOP")
      dblTDOP = GPS.Properties("TDOP")
      dblEPE = GPS.Properties("EPE")
      dblHPE = GPS.Properties("HPE")
      dblVPE = GPS.Properties("VPE")
      
      MsgBox "Latitude: " & CStr(dblLatitude) &_
             ", Longitude: " & CStr(dblLongitude) &_
             ", Altitude: " & CStr(dblAltitude) & Vbcr &_
             "X: " & CStr(dblX) & ", Y: " & CStr(dblY) & ", Z: " & CStr(dblZ) _
             & Vbcr & "PDOP:" & CStr(dblPDOP) &_
             ", VDOP: " & CStr(dblVDOP) &_
             ", HDOP: " & CStr(dblHDOP) &_
             ", TDOP: " & CStr(dblTDOP) & Vbcr &_
             "EPE:" & CStr(dblEPE) &_
             ", HPE: " & CStr(dblHPE) &_
             ", VPE: " & CStr(dblVPE) _
             ,vbInformation, "GPS Position and Quality"
End Sub